
var $titItem = mui("#sort-title .mui-scroll .mui-control-item");

/*分类列表动态逻辑*/
mui.each($titItem,function(index,item){
	
		item.addEventListener("tap",function(event){
		  var _index =parseInt(this.getAttribute("data-index"));
		  drawContent(_index);
		});
}) ;

function drawContent(index){
		/*数据*/
	var arr = new Array(10);
	var data= {"arr":arr};
	
	var arrJs=["hlgjJs","hyjdJs","hlchJs","hssyJs","mylxJs","sdjgJs"];
	
	/*筛选框分类*/
	var sortData ={};
		sortData["hlchJs"]=["策划商家*hlchJs","策划案例*chalJs"];
		sortData["hssyJs"]=["摄影商家*hssyJs","摄影套系*cytxJs"];
		sortData["sdjgJs"]=["婚礼司仪*sdjgJs","婚礼化妆*sdjgJs","婚礼摄像*sdjgJs","婚礼摄影*sdjgJs"];
	/*筛选框内容*/
	var selectData={};
	
	selectData["sortData"]=sortData[arrJs[index]];//筛选框分类加到内容里面去
	
	//console.log(selectData);
	var selectHtml = template("selectJs",selectData);
	//console.log(selectHtml);
	
	/*渲染筛选框*/
	mui("#selectWrap")[0].innerHTML=selectHtml;
	addSelectEvent(data);
	/*筛选框添加事件*/
	 

	/*婚礼管家列表*/
//	var html = template("hlgjJs",data);
	/*婚宴酒店列表*/
//	var html = template("hyjdJs",data);
	/*婚礼策划列表*/
//	var html = template("hychJs",data);
	/*婚纱摄影列表*/
//	var html = template("hssyJs",data);

	var html = template(arrJs[index],data);
//	var html = template("chalJs",data);
	mui("#content-wrap")[0].innerHTML=html;
}
drawContent(0);

function addSelectEvent(data){
	
	/*筛选分类事件*/
	mui(".select-sort .select-btn").each(function(index,item){
		item.addEventListener("tap",function(event){
			
			//没有active类
			if(this.className.indexOf("active")==-1)
			{
				for(var i=0;i<this.parentNode.children.length;i++)
				{
					this.parentNode.children[i].className="select-btn";
				}
				this.className="select-btn active";
				
				var str =this.getAttribute("data-draw");
				console.log(str);
				var html = template(str,data);
				mui("#content-wrap")[0].innerHTML=html;
			}else {
				if(this.querySelector("span").className.indexOf("icon-up")==-1)
				{
					this.querySelector("span").className="icon-up";
					mui('.select')[0].className="select select-hidden";
				} else {
					this.querySelector("span").className="icon-down";
					mui('.select')[0].className="select";
				}
				//mui(".select")[0].style.
			}
	
		})
	})
	
	/*筛选内容事件*/
	mui(".select-content ul li").each(function(index,item){
		
		item.addEventListener("tap",function(event){
			for(var i=0;i<this.parentNode.children.length;i++)
			{
				this.parentNode.children[i].className="";
			}
			this.className="active";
		})
	})
}

function addSelectSort(data){ 
	
}